package com.ml.carManager.widgets;

import android.content.Context;
import android.util.AttributeSet;

import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;

import com.bumptech.glide.request.RequestListener;
import com.ml.carManager.R;
import custom.base.utils.GlideUtils;


/**
 * Created by thl on 2016-03-25.
 */
public class SyncImageView extends AppCompatImageView {

    public SyncImageView(Context context) {
        super(context);
    }

    public SyncImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public SyncImageView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    /**
     * 加载图片
     *
     * @param url
     * @param defaultResourceId
     */
    public void displayImage(String url, @DrawableRes int defaultResourceId) {
//        ImageLoadUtil.getInstance().displayImage(url, this, defaultResourceId);
        GlideUtils.getInstance().displayImageView(url, this, defaultResourceId);
    }

    /**
     * 加载图片
     *
     * @param url
     */
    public void displayThumbnailImageView(String url, float thumbnail) {
        GlideUtils.getInstance().displayThumbnailImageView(url, this, thumbnail);
    }

    /**
     * 加载图片
     *
     * @param url
     * @param defaultResourceId
     */
    public void displayImage(String url, @DrawableRes int defaultResourceId, @Nullable RequestListener requestListener) {
//        ImageLoadUtil.getInstance().displayImage(url, this, defaultResourceId, listener);
        GlideUtils.getInstance().displayImageView(url, this, requestListener, defaultResourceId);
    }

    /**
     * 加载图片
     *
     * @param url
     */
    public void displayImage(String url) {
        displayImage(url, R.drawable.rect_loading_bg);
    }

    /**
     * 加载图片
     *
     * @param url
     */
    public void displayImage(String url, @Nullable RequestListener requestListener) {
        displayImage(url, R.drawable.rect_loading_bg, requestListener);
    }

//    /**
//     * 加载图片
//     *
//     * @param url
//     * @param defaultResourceId
//     */
//    public void displayImage(String url, @DrawableRes int defaultResourceId, @DrawableRes int errorResource) {
//        ImageLoadUtil.getInstance().displayImage(url, this, defaultResourceId, errorResource);
//    }

}
